<?php
declare(strict_types=1);
/**
 * Created by PhpStorm
 * User: Administrator
 * Date: 2023/7/13
 * Time: 13:57:19
 */

namespace App\Controller\WebApi\v1;

use App\Controller\AbstractController;
use App\Middleware\WebApiMiddleware;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middleware;
use Hyperf\HttpServer\Annotation\RequestMapping;
use Hyperf\HttpServer\Contract\RequestInterface;
use Service\DecorateService\DecorateService;

use Service\FileService\UploadFileService;

/**
 * 装修
 * @Controller(prefix="/webapi/v1/decorate")
 * @Middleware(WebApiMiddleware::class)
 */
class DecorateController extends AbstractController
{
    /**
     * @Inject()
     * @var DecorateService
     */

    protected $decorateService;

    /**
     * 首页装修数据
     * @RequestMapping(path="decorate",methods="post")
     */
    public function Decorate(RequestInterface $request){
        $param = $request->inputs(['mn_sid','cid','mnid','isPreview','previewID','decorate_id','is_formal']);
        $param['mid'] = $request->getAttribute('mid');
        return $this->decorateService->Decorate($param);
    }

    /**
     *获取一场秒杀或拼团
     * @RequestMapping(path="lastActivity",methods="post")
     */
    public function lastActivity(RequestInterface $request){
        $param = $request->inputs(['mn_sid','cid','mnid','type','activity_id']);
        $param['mid'] = $request->getAttribute('mid');
        return $this->decorateService->lastActivity($param);
    }

    /**
     * 最近一场特价
     * @RequestMapping(path="lastSpecActivity",methods="post")
     */
    public function lastSpecActivity(RequestInterface $request){
        $param = $request->inputs(['mn_sid','cid','mnid','type']);
        $param['mid'] = $request->getAttribute('mid');
        return $this->decorateService->lastSpecActivity($param);
    }

    /**
     *商品分组商品列表
     * @RequestMapping(path="groupGoodslist",methods="post")
     */
    public function groupGoodslist(RequestInterface $request){
        $param = $request->inputs(['mn_sid','cid','mnid','page','limit','group_id']);
        $param['mid'] = $request->getAttribute('mid');
        return $this->decorateService->groupGoodslist($param);
    }

    /**
     *商品分组商品列表
     * @RequestMapping(path="test",methods="post")
     */
    public function test(RequestInterface $request){
        $param = $request->all();
        $param['mid'] = $request->getAttribute('mid');
        $file = $request->file('file');
        return (new \Service\CommdityService\GoodsClassService())->del($param);
    }
}